package com.tulingxueyuan.mall.controller;

import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.modules.pms.model.dto.*;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductCategoryService;
import com.tulingxueyuan.mall.modules.sms.model.SmsHomeAdvertise;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeAdvertiseService;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeCategoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

/**
 * 首页控制器
 */
@RestController
@Api(tags = "HomeController",description = "首页内容管理")
@RequestMapping("/home")
public class HomeController {
    @Autowired
    private PmsProductCategoryService productCategoryService;
    @Autowired
    private SmsHomeAdvertiseService smsHomeAdvertiseService;
    @Autowired
    private SmsHomeCategoryService homeCategoryService;
    /**
     * 获取首页类型导航栏和数据
     * get("/home/menus")
     */
    @GetMapping(value = "/menus_banner")
    public CommonResult getMenus(){
        // 分类导航
        List<HomeMenusDTO> list= productCategoryService.getMenus();
        HomeMenusBannerDTO homeMenusBannerDTO = new HomeMenusBannerDTO();
        homeMenusBannerDTO.setHomeMenusList(list);
        //查询广告横幅
        List<SmsHomeAdvertise> homeAdvertisesList=smsHomeAdvertiseService.getHomeBanners();
        homeMenusBannerDTO.setHomeAdvertisesList(homeAdvertisesList);
        return CommonResult.success(homeMenusBannerDTO);
    }
    /**
     * /goods_sale
     */
    @GetMapping(value = "/goods_sale")
    public CommonResult getGoodsSale(){
      List<HomeGoodsSaleDTO>  list= homeCategoryService.getGoodsSale();
        return CommonResult.success(list);
    }


}
